<?php
/**
 * @package    DPCalendar
 * @author     Digital Peak http://www.digital-peak.com
 * @copyright  Copyright (C) 2007 - 2014 Digital Peak. All rights reserved.
 * @license    http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

defined('_JEXEC') or die();

JFactory::getApplication()->enqueueMessage(JText::_('COM_DPCALENDAR_VIEW_TOOLS_IMPORT_WARNING'), 'warning');

JPluginHelper::importPlugin('dpcalendar');
?>
<form action="<?php echo JRoute::_('index.php?option=com_dpcalendar&task=import.add'); ?>" method="post" name="adminForm" id="adminForm">
	<fieldset id="filter-bar">
		<div class="filter-search fltlft">
			<label class="filter-search-lbl" for="filter_search"><?php echo JText::_('JSEARCH_FILTER_LABEL'); ?></label>
			<input type="text" name="filter_search" id="filter_search" value="" title="<?php echo JText::_('COM_DPCALENDAR_SEARCH_IN_TITLE'); ?>" />

			<label class="filter-search-lbl" for="filter_search_start"><?php echo JText::_('COM_DPCALENDAR_FIELD_START_DATE_LABEL'); ?> &gt;:</label>
			<?php echo JHtml::_('calendar',
					$this->escape(DPCalendarHelper::getDate()->format('Y-m-d')),
					'filter_search_start',
					'filter_search_start', '%Y-%m-%d',
					array('class' => 'inputbox', 'maxlength' => '10', 'size' => '10'));?>

			<label class="filter-search-lbl" for="filter_search_end"><?php echo JText::_('COM_DPCALENDAR_FIELD_END_DATE_LABEL'); ?> &lt;:</label>
			<?php
			$end = DPCalendarHelper::getDate();
			$end->modify('+2 month');
			echo JHtml::_('calendar',
				$this->escape($end->format('Y-m-d')),
				'filter_search_end',
				'filter_search_end',
				'%Y-%m-%d',
				array('class' => 'inputbox', 'maxlength' => '10', 'size' => '10'));?>

			<?php
				$tmp = JDispatcher::getInstance()->trigger('onCalendarsFetch');
				$calendars = array();
				if (!empty($tmp))
				{
					foreach ($tmp as $tmpCalendars)
					{
						foreach ($tmpCalendars as $calendar)
						{
							$calendars[] = $calendar;
						}
					}
				}
				foreach (JPluginHelper::getPlugin('dpcalendar') as $plugin)
				{
				JFactory::getLanguage()->load('plg_dpcalendar_' . $plugin->name, JPATH_PLUGINS . DS . 'dpcalendar' . DS . $plugin->name);
				?>
				<fieldset class="panelform">
				<legend><?php echo JText::_('PLG_' . $plugin->name)?></legend>
				<ul class="adminformlist">
				<?php
					foreach ($calendars as $cal)
					{
						if ($cal->plugin_name != $plugin->name)
						{
							continue;
						}?>
					<li><input type="checkbox" name="calendar[]" value="<?php echo $cal->id;?>"/>
						<label><?php echo $cal->title;?></label></li>
				<?php
					} ?>
				</ul>
				</fieldset>
			<?php
				}?>

		</div>
	</fieldset>
	<input type="hidden" name="task" value="" />
	<?php echo JHtml::_('form.token'); ?>
</form>

<div align="center" style="clear: both">
	<?php echo sprintf(JText::_('COM_DPCALENDAR_FOOTER'), JRequest::getVar('DPCALENDAR_VERSION'));?>
</div>
